package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.RoleMappMenuMapper;
import com.eos.orm.mybatis.model.RoleMappMenu;
import com.eos.orm.mybatis.model.RoleMappMenuExample;

/**
 * role_mapp_menu角色菜单映射关系表的CURD操作
 * 
 * @author sz
 * 
 */
public class RoleMappMenuMapperImpl extends AbstractSqlSessionFactory implements
		RoleMappMenuMapper {

	public int countByExample(RoleMappMenuExample example) {
		return 0;
	}

	public int deleteByExample(RoleMappMenuExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			RoleMappMenuMapper mapper = session
					.getMapper(RoleMappMenuMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.RoleMappMenuMapperImpl.deleteByPrimaryKey throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

	public int insert(RoleMappMenu record) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			RoleMappMenuMapper mapper = session
					.getMapper(RoleMappMenuMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.RoleMappMenuMapperImpl.insert throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

	public int insertSelective(RoleMappMenu record) {
		return 0;
	}

	public List<RoleMappMenu> selectByExample(RoleMappMenuExample example) {
		List<RoleMappMenu> templist = new ArrayList<RoleMappMenu>();
		SqlSession session = sqlSessionFactory.openSession();
		try {
			RoleMappMenuMapper mapper = session
					.getMapper(RoleMappMenuMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.RoleMappMenuMapperImpl.selectByExample throws exception:"
							+ e.getMessage());
		} finally {
			session.close();
		}
		return templist;
	}

	public RoleMappMenu selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			RoleMappMenuMapper mapper = session
					.getMapper(RoleMappMenuMapper.class);
			return mapper.selectByPrimaryKey(id);
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.RoleMappMenuMapperImpl.selectByPrimaryKey throws exception:"
							+ e.getMessage());
		} finally {
			session.close();
		}
		return null;
	}

	public int updateByExample(RoleMappMenu record, RoleMappMenuExample example) {
		return 0;
	}

	public int updateByExampleSelective(RoleMappMenu record,
			RoleMappMenuExample example) {
		return 0;
	}

	public int updateByPrimaryKey(RoleMappMenu record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(RoleMappMenu record) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			RoleMappMenuMapper mapper = session
					.getMapper(RoleMappMenuMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.RoleMappMenuMapperImpl.updateByPrimaryKeySelective throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

}
